import { Component, OnInit, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';

@Component({
  selector: 'task-confirm',
  template: `
   <h1 mat-dialog-title>{{title}}</h1>
    <div mat-dialog-content>
       {{content}}
    </div>
    <div mat-dialog-actions>
      <button mat-button (click)="onClick(true)">确定</button>
      <button mat-button matDialogClose (click)="onClick(false)">取消</button>
    </div>
  `,
  styles: []
})
export class ConfirmComponent implements OnInit {
  title = '';
  content = '';
  constructor(@Inject(MAT_DIALOG_DATA) private data, private dialogRef: MatDialogRef<ConfirmComponent>) { }

  ngOnInit() {
    this.title = this.data.title;
    this.content = this.data.content;
  }
  onClick(result: boolean) {
    this.dialogRef.close(result);
    console.log(result);
  }
}
